<?php
namespace app\admin\controller;
use \think\Controller;
use think\Db;
class Common extends CommController{
    public function insert_teacher()
    {
        $tea_id=input('tea_id');
        $pass=input('password');
        $name=input('name');
        $title=input('title');
        $sex=input('sex');
        $dept=input('dept');
        $dupt=input('dupt');
        $istrue=Db::table('teacher')->where('tea_id',$tea_id)->select();
        if (!$istrue) {
            $insert=Db::table('teacher')->insert(['tea_id'=>$tea_id,'password'=>$pass,'name'=>$name,'title'=>$title,'sex'=>$sex,'dept'=>$dept,'dupt'=>$dupt]);
            if($insert){
            $this->success('添加成功!','usermanage/teacher_info');
            }
            else
            {
            $this->error('添加错误!','usermanage/teacher_info');
            }
        }
        else
        {
            $this->error('添加失败!该工号已存在!','usermanage/teacher_info');
        }
    }
        
}